package com.dx.order.controller;

import com.dx.model.OrderInfo;
import com.dx.model.UserInfo;
import com.dx.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by lzh on 2017/10/23.
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "getOrderInfoById",method = RequestMethod.GET)
    public OrderInfo getOrderInfoById(Integer orderId){
        return orderService.getOrderInfoById(orderId);
    }

    @RequestMapping(value = "getUserInfoByOrderId",method = RequestMethod.GET)
    public UserInfo getUserInfoByOrderId(Integer orderId){
        return orderService.getUserInfoByOrderId(orderId);
    }

    @RequestMapping(value = "getUserIdByOrderId",method = RequestMethod.GET)
    public String getUserIdByOrderId(Integer orderId){
        return orderService.getUserIdByOrderId(orderId);
    }

    @RequestMapping(value = "getOrderInfoByDate",method = RequestMethod.GET)
    public OrderInfo getOrderInfoByDate(@DateTimeFormat(pattern = "yyyy-MM-dd")Date date){
        return orderService.getOrderInfoByDate(date);
    }
}
